class RegistrationMethodsController < ApplicationController
  before_action :set_registration_method, only: [:show, :edit, :update, :destroy]

  # GET /registration_methods
  # GET /registration_methods.json
  def index
    @registration_methods = RegistrationMethod.all
  end

  # GET /registration_methods/1
  # GET /registration_methods/1.json
  def show
  end

  # GET /registration_methods/new
  def new
    @registration_method = RegistrationMethod.new
  end

  # GET /registration_methods/1/edit
  def edit
  end

  # POST /registration_methods
  # POST /registration_methods.json
  def create
    @registration_method = RegistrationMethod.new(registration_method_params)

    respond_to do |format|
      if @registration_method.save
        format.html { redirect_to new_appointment_path, notice: 'Registration method was successfully created.' }
        format.json { render :show, status: :created, location: @registration_method }
      else
        format.html { render :new }
        format.json { render json: @registration_method.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /registration_methods/1
  # PATCH/PUT /registration_methods/1.json
  def update
    respond_to do |format|
      if @registration_method.update(registration_method_params)
        format.html { redirect_to @registration_method, notice: 'Registration method was successfully updated.' }
        format.json { render :show, status: :ok, location: @registration_method }
      else
        format.html { render :edit }
        format.json { render json: @registration_method.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /registration_methods/1
  # DELETE /registration_methods/1.json
  def destroy
    @registration_method.destroy
    respond_to do |format|
      format.html { redirect_to registration_methods_url, notice: 'Registration method was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_registration_method
      @registration_method = RegistrationMethod.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def registration_method_params
      params.require(:registration_method).permit(:label, :created_at, :updated_at, :created_by, :updated_by)
    end
end
